<?php

declare(strict_types=1);

namespace App\CustHub\Controller\Admin;
use App\CustHub\Controller\BaseController;
use App\CustHub\Request\ChRobotRequest;
use App\CustHub\Service\ChGetRobotService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PutMapping;
use Mine\Annotation\Auth;
use Mine\Annotation\Permission;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

#[Controller(prefix: "ch/admin/chGetRobot"),Auth]
class ChGetRobotController extends BaseController
{
    #[Inject]
    protected ChGetRobotService $service;

    /**
     * 获取机器人列表
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    #[GetMapping('index'),Permission("ch:admin:chGetRobot:index")]
    public function getRobot(): ResponseInterface
    {
        return $this->success($this->service->getRobot($this->request->all()));
    }


    #[PutMapping('changeServer/{id}'),Permission("ch:admin:chGetRobot:changeServer")]
    public function changeServer(int $id,ChRobotRequest $request): string
    {
        return $this->service->changeServer($id,$request->all()) ? '操作成功': '操作失败';
    }
}
